"use client"

import type React from "react"
import { useEffect } from "react"
import { useMessage } from "./message-context"
import { setMessageInstance } from "./index"

export const MessageInitializer: React.FC = () => {
    const messageInstance = useMessage()

    useEffect(() => {
        setMessageInstance(messageInstance)
        return () => {
            // 清理函数，当组件卸载时执行
            setMessageInstance({
                addMessage: () => { },
                removeMessage: () => { },
            })
        }
    }, [messageInstance])

    return null
}

